<!DOCTYPE html>
<html lang="zh">
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<meta http-equiv="X-UA-Compatible" content="ie=edge">
		<title>机构端</title>
        <script src="/Public/static/jquery-2.0.3.min.js"></script>
        <script src="/Public/static/layer/layer.js"></script>
        <link rel="stylesheet" href="__PUBLIC__/Home/css/reset.css">
        <link rel="stylesheet" href="__PUBLIC__/Home/css/style.css">
        <link rel="stylesheet" href="__PUBLIC__/Home/css/page.css" />
	</head>

	<body class="agency_box contentBox pos_rel dpflxr">
		<!-- 1.顶部logo导航 -->
		<include file="head" />

		<!-- 2.垂直导航 -->
		<div class="navColumn">
			<a href="{:U('Mechanism/floor_index')}" <if condition="$cur eq 楼盘管理">class="navColumnItem actived dpflxr pos_rel"<else />class="navColumnItem  dpflxr pos_rel"</if> data-type='1'>
				<div class="lineColumn pos_abs"></div>
				<label for="">楼盘管理</label>
				<div class="rightArrow">
				</div>
			</a>
			<a href="{:U('Mechanism/house_type')}"  <if condition="$cur eq 户型管理">class="navColumnItem actived dpflxr pos_rel"<else />class="navColumnItem  dpflxr pos_rel"</if> data-type='2'>
				<div class="lineColumn pos_abs"></div>
				<label for="">户型管理</label>
				<div class="rightArrow">
				</div>
			</a>
			<a href="{:U('Mechanism/build_manage')}" <if condition="$cur eq 楼栋管理">class="navColumnItem actived dpflxr pos_rel"<else />class="navColumnItem  dpflxr pos_rel"</if>  data-type='3'>
				<div class="lineColumn pos_abs"></div>
				<label for="">楼栋管理</label>
				<div class="rightArrow">
				</div>
			</a>
			<a href="{:U('Mechanism/souse_res')}" <if condition="$cur eq 房源管理">class="navColumnItem actived dpflxr pos_rel"<else />class="navColumnItem  dpflxr pos_rel"</if>  data-type='4'>
				<div class="lineColumn pos_abs"></div>
				<label for="">房源管理</label>
				<div class="rightArrow">
				</div>
			</a>
			
		</div>



		<!-- 二 3.1 楼栋管理  -->
		<div class="contentArea  actived">
			<!-- 3.1.1 生成房间 -->
			<div class="addProject">
				<div class="caTitleBox dpflxr">
					<label for="" class="caTitle">生成房间</label>
				</div>
				
				
			
					<div class="switchPage  card dpflxr">
						<volist name="list" id="item">
						<div class="spTitle dpflxrw" name="unit_number" data-un="{$item['id']}">{$item['id']}单元</div>
						
						<div class="contentItem  dpflxr ">
							<label for="" class="title">楼层数：</label>
							<div class="pos_rel">
								<input type="text" name="layer" value="{$item['layer']}" readonly="true" class="inputBox" placeholder="25" 
									placeholder-style="font-size:16px;line-height:48px;color:#bfa;"/>			
							</div>						
						</div>
						<div class="contentItem  dpflxr ">
							<label for="" class="title">起始房号：</label>
							<div class="pos_rel">
								<input type="text" class="inputBox"  name="start" readonly="true" value="1" placeholder="1" 
									placeholder-style="font-size:16px;line-height:48px;color:#bfa;"/>			
							</div>						
						</div>
						<div class="contentItem  dpflxr ">
							<label for="" class="title">结束房号：</label>
							<div class="pos_rel">
								<input type="text" class="inputBox"  name="end" data-id="" placeholder="一层楼有几户，就填数字几" 
									placeholder-style="font-size:16px;line-height:48px;color:#bfa;"/>			
							</div>						
						</div>
						</volist>	

						
						
						

																																				
						<div class="ciBtnWrapper">
							<div class="ciBtn"><label>确认</label></div>
						</div>
						
					
					</div>
				
				


			</div>
		
			<!-- 3.1.2 房间明细 -->
			<div class="roomDetail">
				<div class="caTitleBox dpflxr">
					<label for="" class="caTitle">房间明细</label>
				</div>
				
<!-- 				<div class="markBar dpflxrw">
					<div class="markItem dpflxr">
						<div class="markColor"></div>
						<label for="">待售405</label>
					</div>
				</div> -->
				<div class="roomSheetWrapper card">
					<div class="roomSheet ">
						<div class="header dpflxr">

						</div>

					</div>
					
				</div>
				
										
			</div>							
		</div>						
	</body>
</html>
<script type="text/javascript">
	var list1={$list1};
	var build_id={$id};
	var floor_id={$floor_id};
	$("body").on('click','.ciBtn',function(){
		var layer=$("input[name='layer']").val();
		var ll = $("input[name='end']");
		
		var chk=[];
		for (var ii = 0; ii < ll.length; ii++) {
			var jj = ll.eq(ii).val();
			chk.push(jj);
		}
		// console.log(list1);

	    var gg='';
	    var pp=1;
		for(iii=0;iii<layer;iii++){

			var hh='';
			gg+='<div class="floor dpflxr">';
			gg+='<div class="fNum">'+pp+'</div>'
		    hh+='<div class="hStart"></div>';

		    var tt=0;
	        $.each(list1,function(k,v){
	        	var op=chk[k];
	        	hh+='<div class="roomCell" style="min-width:calc(100px * '+op+');" id="t'+tt+'">'+v.id+'单元</div>';
	        	// document.getElementById("t'+tt+'").style.width="500px";
	        	// $("#t"+tt).width(500);
	        	// $(this).css("width", 500);
	        	//var box = document.getElementById("t0");
				// console.log(box);
				// box.style.width == '500px';
	        	
	        	// console.log(op);
	        	gg+='<div class="roomCell dpflxr">';
	        	var pi=1;
		        for (var i = 0; i < op; i++) {
		     		// console.log(i);
		        	gg+='<label class="room">'+pp+'0'+pi+'</label>';
		        	pi++;
				}
				gg+='</div>';
				tt++;
	        })
	        gg+='</div>';

	        $('.header').html(hh);
	        pp++;
		}
        $('.roomSheet').append(gg);


    	var unit_number=$("div[name='unit_number']");
    	// console.log(unit_number.length);
    	// var chk1=[];
		for (var ii1 = 0; ii1 < unit_number.length; ii1++) {
			var jj1 = unit_number.eq(ii1).attr('data-un');
			
			// chk1.push(jj1);
		}
		var chk1=jj1;//我只需要有几个单元即可

    	var layer=$("input[name='layer']");
    	var chk2=[];
		for (var ii2 = 0; ii2 < layer.length; ii2++) {
			var jj2 = layer.eq(ii2).val();
			chk2.push(jj2);
		}
		// console.log(chk);//结束房号
		// console.log(chk1);//单元号
		// console.log(chk2);//单元总楼层
		// return false;
        $.ajax({
            url:"{:U('Mechanism/save_room')}",
            data:{chk:chk,chk1:chk1,chk2:chk2,build_id:build_id,floor_id:floor_id},
            dataType:'json',
            type:'post',
            success:function(data){
				if (data.result == 1) {
					alert(data.msg);
					$('.ciBtn').hide();
					// var url = "/index.php?s=/Home/Mechanism/build_manage.html";
					// location.href = url;
				} else {
					alert(data.msg);
					// var url = "/index.php?s=/Home/Mechanism/build_manage.html";
					// location.href = url;
				}

            }
        });
	})
</script>